#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <sstream>
#include <math.h>

//#define maxsize 512;

using namespace std;

int reverse(char *str)
{
	int len = 0;
	while(*(str+len) != 0)
		len++;

        char ch;
	int i=0;

        double limit = len/2.0;
        for (i=0;i<floor(limit);i++)
	{
                ch = *(str+i);
		*(str+i) = *(str+len-i-1);
		*(str+len-i-1) = ch;
        }

        *(str+len) = 0;
        i = 0;
        while(*(str+i) != 0)
        {
          cout << *(str+i);
          i++;
        }

        cout <<"\n-----------------------------\n";

	return 0;
}

int main(int argc, char *argv[])
{
	if (argc <2)
	{
		cout << "no input file or string detected\n";
		return 0;
	}

	char *filename = argv[1];
	ifstream infile(filename);

	string str;
	char *in;
	in = (char *)malloc(512*sizeof(char));
	int i=1;
        getline(infile, str);
	while(getline(infile, str))
	{
		i = 1;
		int len = str.size();
		for(int j=0;j<len;j++)
		{
			*(in+j)=str[j];
			i++;
		}
		*(in+len) = 0;
		reverse(in);
        }

	return 0;
}
